# OpenAPI version identifier - required for OpenAPI 3.0 domains
# (c) Elexon 2022, 2023
#
# MMHS - Data Integration Platform 
# DataTypes
#
# ----- update -----------------------------------------------------------------------
# April 2023
#  
#
# ------------------------------------------------------------------------------------
# Change history
# =======================================
# 1.2 17/04/2023 - Fix regex pattern for DT-016-Decimal-9-3
# 1.1 14/03/2023 - Align with mandatory nullable 
#                  correlation Id and transaction Id have been updated to 60
# 1.0 17/02/2023 - Align with DAG signoff
# 0.4 26/01/23  Minor updates 
# 0.3 08/11/22  fix max /min problem 
# 0.2 27/09/22  add DT017 & DT017
# 0.1 26/08/22  Initial Version
# =======================================
# 

openapi: 3.0.0
info:
  title: MHHS Data Types
  description: Common data types for MHHS Message/Event objects
  version: '1.3'
  

# Dictionary items below:
components:
    
  schemas:
# Data type
      
    DT-000-InterfaceID:
      description: Interface ID 
      type: string
      minLength : 6
      maxLength : 8
      example: IF-007
      enum:  
      # list of allowable INFs 
        - IF-001  # Notification of Change of Supplier
        - IF-002  # Notification to New Supplier of Site Information  
        - IF-005  # Metering Service MTD Updates to Registration
        - IF-006  # Registration Service Notification of MTD Updates
        - IF-007  # Change of Energisation Status Outcome
        - IF-008
        - IF-009
        - IF-013
        - IF-014
        - IF-015
        - IF-016
        - IF-018
        - IF-021
        - IF-022
        - IF-023
        - IF-024
        - IF-025
        - IF-026
        - IF-027
        - IF-028
        - IF-031
        - IF-032
        - IF-033
        - IF-034
        - IF-035
        - IF-036
        - IF-037
        - IF-038
        - IF-039
        - IF-041
        - IF-043
        - IF-044
        - IF-045
        - IF-047
        - REP-002
        - REP-002A
        - REP-003
        - REP-004
        - REP-006
        - REP-007
        - REP-008
        - REP-009
   
      
    DT-001N-AddressLine:
      description: Address Line
      type: string
      nullable: true
      minLength : 0
      maxLength : 40
      example: 'Address Line'
  
      
    DT-002-MPAN:
      description: MPAN Core
      type: string
      minLength : 13
      maxLength : 13
      example: '2000056535971'

    DT-002N-MPAN:
      description: MPAN Core
      type: string
      nullable: true
      maxLength : 13
      example: '2000056535971'

      # mandating the full length for data strings, i.e. inclusion of the +hh:mm offset.

    DT-003-DateTime:
      description: ISO 8601 Date/time
      type: string
      minLength : 25
      maxLength : 25
      example: '2022-03-21T19:05:00+00:00'

      
    DT-003N-DateTime:
      description: ISO 8601 Date/time
      type: string
      nullable: true
      minLength : 25
      maxLength : 25
      example: '2022-03-21T19:05:00+00:00'

      # mandating the full length for data strings, i.e. inclusion of the +hh:mm offset.



    DT-004-EventCode:
      description: Event Code
      type: string
      minLength : 1
      maxLength : 50
      example: '[EventName]'
      # not enumerated here as picked up in S0 Payload

    DT-004N-EventCode:
      description: Event Code
      type: string
      nullable: true
      minLength : 1
      maxLength : 50
      example: '[EventName]'
      # not enumerated here as picked up in S0 Payload


    DT-005-StatusErrorMessage:
      description: Status/Error messages
      type: string
      minLength : 1
      maxLength : 200
      example: 'MSG0101 Application 101 error message'

    DT-005N-StatusErrorMessage:
      description: Status/Error messages
      type: string
      nullable: true
      maxLength : 200
      example: 'MSG0101 Application 101 error message'


    DT-006-DIPParticipantID:
      description: DIP Participant Id
      type: string
      minLength : 10
      maxLength : 10
      example: '1009012345'

    DT-006N-DIPParticipantID:
      description: DIP Participant Id
      type: string
      nullable: true
      minLength : 10
      maxLength : 10
      example: '1009012345'
      
    DT-007N-UKPostCode:
      description: UK Post Code 
      type: string
      nullable: true
      minLength : 6
      maxLength : 10
      example: 'SW1A 2AA'
      
      
    DT-008-MeterSerialID:
      description: Meter Serial Id
      type: string
      minLength : 10
      maxLength : 10
      example: 'ZZ99Z12345'
      

    DT-009-DIPParticipantRole:
      description: DIP Participant Role
      type: string
      minLength : 3
      maxLength : 5
      example: 'SUP'

    DT-009N-DIPParticipantRole:
      description: DIP Participant Role
      type: string
      nullable: true
      minLength : 3
      maxLength : 5
      example: 'SUP'

    DT-010-DIPParticipantEZName:
      description: Long Descriptive Participant Name
      type: string
      minLength : 1
      maxLength : 50
      example: 'Very Long Named Energy Co Ltd'
      

    DT-011-CorrelationID:
      description: Correlation Id
      type: string
      minLength : 1
      maxLength : 60
      example: 'CI-20220401-1234567890123abce123092'

    DT-011N-CorrelationID:
      description: Correlation Id
      type: string
      nullable: true
      maxLength : 60
      example: 'CI-20220401-1234567890123abce123092'

#    DT-012-EnvelopeID: ### Removed ####


    DT-013-EnvironmentTag:
      description: Environment Tag 
      type: string
      minLength : 3
      maxLength : 10
      enum: 
        - PROD
        - PREPROD
        - SIT
        - UIT
        - DEV
      example: 'DEV'       
      
    DT-014-DIPTransactionID:
      description: Transaction ID 
      type: string
      maxLength : 60
      example: 'T-006-0123456789-SUP-20220401-1234CC0123456789'  # MHHS-DIN-250 - updated example ParticipantID length = 10

    DT-016-Decimal-9-3:
      description: kWh Consumption (9,3) format 
      type: string
      pattern: ^-?[0-9]\d{8}(\.\d{3})?$
      example: '123456789.123'

    DT-016N-Decimal-9-3:
      description: kWh Consumption (9,3) format 
      type: string
      nullable: true
      pattern: ^-?[0-9]\d{8}(\.\d{3})?$
      example: '123456789.123'


    DT-022-Decimal-9-6:
      description: Number (9,6) format 
      type: string
      pattern: ^-?[0-9]\d{8}(\.\d{6})?$
      example: -987654321.123456

    DT-022N-Decimal-9-6:
      description: Number (9,6) format 
      type: string
      nullable: true
      pattern: ^-?[0-9]\d{8}(\.\d{6})?$
      example: -987654321.123456

    DT-023-Positive-Decimal-9-6:
      description: Number (9,6) format 
      type: string
      pattern : ^[0-9]\d{8}(\.\d{6})?$
      example: 123456789.123456
      
    DT-023N-Positive-Decimal-9-6:
      description: Number (9,6) format 
      type: string
      nullable: true
      pattern : ^[0-9]\d{8}(\.\d{6})?$
      example: 123456789.123456



# D017 dropped

      

    DT-018-URL:
      description: URL
      type: string
      minLength : 1
      maxLength : 250
      example: 'https://<baseURL>/nav_to.do?uri=<table name>.do?sys_id=-1%26sysparm_query=<field=value>'
      
    DT-018N-URL:
      description: URL
      type: string
      nullable: true
      minLength : 1
      maxLength : 250
      example: 'https://<baseURL>/nav_to.do?uri=<table name>.do?sys_id=-1%26sysparm_query=<field=value>'
      
    DT-019-HelpText:
      description: Help Text
      type: string
      minLength : 1
      maxLength : 500
      example: 'Sender Unique reference must take the format S - Interface Id - Participant Id - Role Id - Date - Sequence (hex)/Participant Ref, e.g. ‘S-005-03458900823-SUP-20222313-12345687a’'
      
    DT-020N-SubText:
      description: SubText
      type: string
      nullable: true
      minLength : 1
      maxLength : 500
      example: 'additonal text to separate messages in testing - ignore in production'
      
    DT-021-Date:
      description: ISO 8601 Date
      type: string
      minLength : 10
      maxLength : 10
      example: '2022-03-21'
      # mandating the short length for date strings, i.e. no +hh:mm offset.




    DT-026-Group-Correction-Factor: 
      description: Group Correction Factor (Number 4,2) format 
      type: number
      minimum : 0
      maximum :  99.99
      multipleOf: 0.01
      example: 20.12 

    DT-027-MPID: 
      description: Legacy MPID
      type: string
      minimum: 4
      maximum: 4
      example: 'EMEB'

    DT-027N-MPID: 
      description: Legacy MPID
      type: string
      nullable: true
      minimum: 4
      maximum: 4
      example: 'EMEB'

    DT-029-MeterID: 
      description: Meter ID
      type: string
      maximum: 10
      example: 'A123456789'

    DT-029N-MeterID: 
      description: Meter ID
      nullable: true
      type: string
      maximum: 10
      example: 'A123456789'

      # need to update to inlcude validation ##


      
    DT-983-PublicationID:
      description: Publication ID 
      type: string
      minLength : 6
      maxLength : 8
      example : 'PUB-007'
      enum:  
        - PUB-001  # NotPUBication of Change of Supplier
        - PUB-002  # NotPUBication to New Supplier of Site Information  
        - PUB-005  # Metering Service MTD Updates to Registration
        - PUB-006  # Registration Service NotPUBication of MTD Updates
        - PUB-007  # Change of Energisation Status Outcome
        - PUB-008
        - PUB-009
        - PUB-013
        - PUB-014
        - PUB-015
        - PUB-016
        - PUB-018
        - PUB-021
        - PUB-022
        - PUB-023
        - PUB-024
        - PUB-025
        - PUB-026
        - PUB-027
        - PUB-028
        - PUB-031
        - PUB-032
        - PUB-033
        - PUB-034
        - PUB-035
        - PUB-036
        - PUB-037
        - PUB-038
        - PUB-039
        - PUB-041
        - PUB-043
        - PUB-044
        - PUB-045
        - PUB-047
        - REP-002
        - REP-002A
        - REP-003
        - REP-004
        - REP-006
        - REP-007
        - REP-008
        - REP-009

    DT-995-SenderUniqueReference:
      description: Sender Unique Reference 
      type: string
      minLength : 1
      maxLength : 200
      example: 'S-005-0123456789-SUP-20222313-12345687a1234567a'